import request from '@/config/axios'
// import type { Dayjs } from 'dayjs';

/** 知识库结构树信息 */
export interface Tree {
  id: number; // 数据id
  parentId: number; // 上级节点id
  nodeName: string; // 节点名称
  children?: Tree[];
}

// 知识库结构树 API
export const TreeApi = {
  // 查询知识库结构树列表
  getTreeList: async (params) => {
    return await request.get({ url: `/knowledge/tree/list`, params })
  },

  // 查询知识库结构树详情
  getTree: async (id: number) => {
    return await request.get({ url: `/knowledge/tree/get?id=` + id })
  },

  // 新增知识库结构树
  createTree: async (data: Tree) => {
    return await request.post({ url: `/knowledge/tree/create`, data })
  },

  // 修改知识库结构树
  updateTree: async (data: Tree) => {
    return await request.put({ url: `/knowledge/tree/update`, data })
  },

  // 删除知识库结构树
  deleteTree: async (id: number) => {
    return await request.delete({ url: `/knowledge/tree/delete?id=` + id })
  },


  // 导出知识库结构树 Excel
  exportTree: async (params) => {
    return await request.download({ url: `/knowledge/tree/export-excel`, params })
  },
}
